package com.zsoft.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.queryParser.ParseException;
import org.eclipse.jetty.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.zsoft.index.IndexSearch;
import com.zsoft.service.IndexService;

/**
 * 索引
 * 
 * @author zuoshuaiok@gmail.com
 * 
 *         2013-4-22
 */
@Controller(value = "/search")
public class IndexController {
	@Autowired
	private IndexService service;

	@RequestMapping(value = "/home.htm")
	public ModelAndView index(HttpServletRequest request,
			HttpServletResponse response, String key)
			throws CorruptIndexException, IOException, ParseException {
		ModelAndView mv = new ModelAndView("index");
		// boolean flag = service.test();
		// mv.addObject("flag", flag);
		// System.out.println(Thread.currentThread().getName());

		// if (StringUtils.hasText(key)) {
		// String retResult = IndexSearch.search(key);
		// mv.addObject("result", retResult);
		// }
		return mv;
	}
}
